<template>
  <div style="width: 100%;height:100%">
    <a-form-model
      ref="ruleForm"
      :model="newTaskData"
      :rules="rules"
      class="AsteriskAfter newEditStyle rightDrawerWithoutCol"
    >
      <!-- 升级方式 -->
      <a-row>
        <!-- 升级通道 -->
        <a-col :md="12" :sm="24" v-if="upgradeTriggerType !== 'warehouse'">
          <a-form-model-item prop="channel" label="升级通道">
            <a-radio-group v-model="newTaskData.channel" :disabled="true">
              <a-radio key="ghy" :value="1">
                {{ $t('规划院') }}
              </a-radio>
              <a-radio key="gcy" :value="0">
                {{ $t('工程院') }}
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-model-item prop="type">
            <template #label>
              <span>{{ $t('upgradeType') }}</span>
              <question-mark-tip
                :tip-title="$t(newTaskData.type === 1 ? 'testUserTaskUpgradeTypeTip' : 'testAutoTaskUpgradeTypeTip')"
                :popupContainer="getPopupContainer"
              >
              </question-mark-tip>
            </template>
            <a-radio-group v-model="newTaskData.type" :disabled="upgradeTriggerType == 'warehouse'">
              <a-radio v-for="(item, index) in taskType" :key="index" :value="item.value" v-if="newTaskData.channel === 1 || item.value === '2'">
                {{ $t(item.name) }}
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
        </a-col>

        <!-- 用户升级时显示 是否强制升级-->
        <a-col :md="12" :sm="24" v-if="newTaskData.type === '1'">
          <a-form-model-item prop="forceUpgrade">
            <template #label>
              <span>{{ $t('isQzsj') }}</span>
              <question-mark-tip
                :tip-title="$t('sfqzTip')"
                :popupContainer="getPopupContainer"
              >
              </question-mark-tip>
            </template>
            <a-radio-group v-model="newTaskData.forceUpgrade">
              <a-radio v-for="(item, index) in forceUpgradeType" :key="index" :value="item.value">
                {{ $t(item.name) }}
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
        </a-col>
        <!-- 自动升级时显示 是否静默升级-->
        <a-col :md="12" :sm="24" v-if="newTaskData.type === '2' && upgradeTriggerType == 'warehouse'">
          <a-form-model-item prop="silenceUpgrade">
            <template #label>
              <span>{{ $t('sfjmsj') }}</span>
              <question-mark-tip
                :tip-title="$t('sfjmTip')"
                :popupContainer="getPopupContainer"
              >
              </question-mark-tip>
            </template>
              <a-radio-group v-model="newTaskData.silenceUpgrade">
              <a-radio v-for="(item, index) in slienceUpgradeType" :key="index" :value="item.value">
                {{ $t(item.name) }}
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
        </a-col>
        <!-- 升级策略 -->
        <a-col :md="12" :sm="24"  class="sjclStyle">
          <a-form-model-item class="sjclSelect" :label="$t('sjcl')" prop="strategyId">
            <template v-if="newTaskData.strategyName">
              <span style="padding-right:10px;">{{newTaskData.strategyName}}</span>
              <a-tooltip title="清除">
                <a-button type="link" @click="() => changeStrategyBefore('')"  style="margin-right:10px;">
                  <a-icon type="close"/>
                </a-button>
              </a-tooltip>
              <a-tooltip :title="$t('detail')">
                <a-button @click="showStrategy">
                  <i class="iconfont icon-chakanxiangqing1"></i>
                </a-button>
              </a-tooltip>
            </template>
            <auth-button type="info" v-else-if="strategyPerms.channel"
                         @click="()=>{$refs.strategyTableSelector.setSelectedRowKey(newTaskData.strategyId);$refs.strategyTableSelector.visible=true}"
                         style="margin-right: 10px;">
              {{ $t('select') }}
            </auth-button>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row :gutter="[16,16]">
        <!-- 任务名称 -->
        <a-col :md="8" :sm="24">
          <a-form-model-item :label="$t('campaignName')" prop="name">
            <a-input v-model="newTaskData.name" :maxLength="50" />
          </a-form-model-item>
        </a-col>
        <!-- 超时时长 -->
        <a-col :md="8" :sm="24" v-if="upgradeTriggerType === 'warehouse'">
          <a-form-model-item :label="$t('timeout')+'(分钟)' " prop="duration">
            <a-input-number
              style="width: 100%"
              v-model="newTaskData.duration"
              :placeholder="$t('pleaseInput')+$t('timeout')"
            ></a-input-number>
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="24" v-if="newTaskData.channel === 0">
          <a-form-model-item :label="$t('批次名称')" prop="taskGcyExt.batchName"
                             :rules="{required: true,message: $t('pleaseInput'), trigger: 'change'}">
            <a-input v-model="newTaskData.taskGcyExt.batchName" @input="lenMin(newTaskData.taskGcyExt.batchName)"  :maxLength="100" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="24" v-if="newTaskData.channel === 0">
          <a-form-model-item :label="$t('申请人')" prop="taskGcyExt.applyUserId"
                             :rules="{required: true,message: $t('pleaseSelect'), trigger: 'change'}">
            <a-select
              v-model="newTaskData.taskGcyExt.applyUserId"
              show-search
              :filter-option="$commonFun.filterOption"
            >
              <a-select-option
                v-for="user in gcyApplyUsers" :value="user.id"
                :key="user.id"> {{ user.name }}  [{{user.account}}] [{{user.email}}] </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="24" v-if="newTaskData.channel === 0">
          <a-form-model-item :label="$t('审批人')" prop="taskGcyExt.auditUserId"
                             :rules="{required: true,message: $t('pleaseSelect'), trigger: 'change'}">
            <a-select
              v-model="newTaskData.taskGcyExt.auditUserId"
              show-search
              :filter-option="$commonFun.filterOption"
            >
              <a-select-option
                v-for="user in gcyAuditUsers" :value="user.id"
                :key="user.id"> {{ user.name }}  [{{user.account}}] [{{user.email}}] </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <!-- 有效期 -->
<!--        <a-col>-->
<!--          <a-form-model-item :label="$t('expirationDate')" :required="true">-->
<!--            <a-form-model-item-->
<!--              prop="startTime"-->
<!--              :style="{ display: 'inline-block', width: 'calc(50% - 12px)', marginBottom: 0 }"-->
<!--            >-->
<!--              <a-date-picker-->
<!--                :showTime="{ format: 'HH:mm' }"-->
<!--                format="YYYY-MM-DD HH:mm"-->
<!--                :disabledDate="disabledStartDate"-->
<!--                @openChange="handleStartOpenChange"-->
<!--                style="width: 100%"-->
<!--                v-model="newTaskData.startTime"-->
<!--              />-->
<!--            </a-form-model-item>-->
<!--            <span :style="{ display: 'inline-block', width: '24px', textAlign: 'center' }">-</span>-->
<!--            <a-form-model-item-->
<!--              prop="endTime"-->
<!--              :style="{ display: 'inline-block', width: 'calc(50% - 12px)', marginBottom: 0 }"-->
<!--            >-->
<!--              <a-date-picker-->
<!--                :showTime="{ format: 'HH:mm' }"-->
<!--                format="YYYY-MM-DD HH:mm"-->
<!--                :disabledDate="disabledEndDate"-->
<!--                :open="endOpen"-->
<!--                @openChange="handleEndOpenChange"-->
<!--                style="width: 100%"-->
<!--                v-model="newTaskData.endTime"-->
<!--              />-->
<!--            </a-form-model-item>-->
<!--          </a-form-model-item>-->
<!--        </a-col>-->
        <!-- 备案号 -->
        <a-col>
          <a-form-model-item :label="$t('备案流程编号')" prop="recordNo">
            <a-input v-model="newTaskData.recordNo" :maxLength="200"/>
          </a-form-model-item>
        </a-col>
        <!-- 备注 -->
        <a-col>
          <a-form-model-item :label="$t('升级原因')" prop="remark">
            <custom-text-area
              @change="newTaskData.remark = $event"
              :val="newTaskData.remark"
              :max-len="200"
            ></custom-text-area>
          </a-form-model-item>
        </a-col>
        <!-- 唤醒通道 -->
        <a-col v-if="newTaskData.type === '2' &&  upgradeTriggerType !== 'warehouse'">
          <a-form-model-item :label="$t('hxtd')" prop="factoryChannel">
            <factory-channel-select
              :default-value="newTaskData.factoryChannel"
              @changeoption="changeoption($event,'factoryChannel')"
            >
            </factory-channel-select>
          </a-form-model-item>
        </a-col>
        <a-col v-if="upgradeTriggerType !== 'warehouse'">
          <a-form-model-item :label="$t('OTA升级范围')" prop="taskGcyExt.updateScope"
                             :rules="{required: true,message: $t('pleaseSelect'), trigger: 'change'}">
            <a-select
              v-model="newTaskData.taskGcyExt.updateScope"
              mode="multiple"
              optionFilterProp="children"
              :filterOption="$commonFun.filterOption"
              showSearch
              placeholder="OTA升级范围"
              allow-clear
              style="width:100%"
            >
              <a-select-option v-for="(item,i) in gcyOtaUpdateScopeDictCode" :key="'updateScope'+i" :value="item.name" :title="item.name">{{item.name}}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col>
          <a-form-model-item :label="$t('供应商验证结论')" prop="taskGcyExt.supplierVerifyConclusion"
                             :rules="{required: true,message: $t('pleaseSelect')}">
            <a-select
              v-model="newTaskData.taskGcyExt.supplierVerifyConclusion"
              optionFilterProp="children"
              :filterOption="$commonFun.filterOption"
              showSearch
              placeholder="供应商验证结论"
              allow-clear
              style="width:100%"
            >
              <a-select-option v-for="(item,i) in gcyOtaSupplierVerifyResultDictCode" :key="'supplierVerifyConclusion'+i" :value="item.value" :title="item.name">{{item.name}}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col>
          <a-form-model-item :label="$t('产品验证结论')" prop="taskGcyExt.productVerifyConclusion"
                             :rules="{required: true,message: $t('pleaseSelect')}">
            <a-select
              v-model="newTaskData.taskGcyExt.productVerifyConclusion"
              optionFilterProp="children"
              :filterOption="$commonFun.filterOption"
              showSearch
              placeholder="产品验证结论"
              allow-clear
              style="width:100%"
            >
              <a-select-option v-for="(item,i) in gcyOtaSupplierVerifyResultDictCode" :key="'productVerifyConclusion'+i" :value="item.value" :title="item.name">{{item.name}}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-divider orientation="left">附件</a-divider>
      <a-row>
        <a-col>
          <a-form-model-item :label="$t('升级准入证明')" prop="taskGcyExt.upgradeAccessProve"
                             :rules="{required: true,message: '请上传文件'}">
              <FileUploader v-model="newTaskData.taskGcyExt.upgradeAccessProve"/>
<!--        TODO: 限制文件类型    :accept="['.xls','.xlsx']"-->
          </a-form-model-item>
        </a-col>
        <a-col v-for="(cfg,key) in taskFileConfig" :key="key">
          <a-form-model-item :label="$t('是否上传' + cfg.name)" :prop="'taskGcyExt.' + cfg.boolKey" required style="margin-bottom:0">
            <a-radio-group v-model="newTaskData.taskGcyExt[cfg.boolKey]" @change="$nextTick(()=>$refs.ruleForm.clearValidate(['taskGcyExt.' + cfg.reasonKey, 'taskGcyExt.' + cfg.key]))">
              <a-radio :key="cfg.boolKey + '1'" :value="true">
                {{ $t('yes') }}
              </a-radio>
              <a-radio :key="cfg.boolKey + '0'" :value="false">
                {{ $t('no') }}
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
<!--          :label="$t('不上传'+ cfg.name +'原因')"-->
          <a-form-model-item :prop="'taskGcyExt.' + cfg.reasonKey" v-if="newTaskData.taskGcyExt[cfg.boolKey] === false"
                             :rules="[{required: true,message: '原因不能为空'}, {max:100, message: '长度不能超过100'}]">
            <custom-text-area
              @change="newTaskData.taskGcyExt[cfg.reasonKey] = $event"
              :val="newTaskData.taskGcyExt[cfg.reasonKey]"
              :rows="2"
              :placeholder="$t('不上传'+ cfg.name +'原因')"
              :max-len="100"
            />
          </a-form-model-item>
<!--          :label="$t(cfg.name)"-->
          <a-form-model-item :prop="'taskGcyExt.' + cfg.key" v-else
                             :rules="{required: true,message: '请上传文件', trigger: 'change'}">
            <FileUploader v-model="newTaskData.taskGcyExt[cfg.key]" @change="newTaskData.taskGcyExt[cfg.key] = $event"/>
            <!--        TODO: 限制文件类型    :accept="['.xls','.xlsx']"-->
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    <!-- 查看策略 -->
    <show-condition-update-strategy
      ref="showStrategy"
      :updataStrategyId="newTaskData.strategyId"
    ></show-condition-update-strategy>
    <StrategyTableSelector ref="strategyTableSelector"
                           :version-type="'PROD'"
                           :test-type="'channel'"
                           v-if="upgradeTriggerType"
                           :upgrade-trigger-type="newTaskData.type === 1 ? 'USER' : 'AUTO'"
                           @ok="(id) => changeStrategyBefore(id)"/>
  </div>
</template>
<script>
import moment from 'moment'
import ShowConditionUpdateStrategy from '@/views/components/ShowConditionUpdateStrategy'
import FactoryChannelSelect from '@/views/components/FactoryChannelSelect.vue'
import {mapMutations, mapState} from 'vuex'
import StrategyTableSelector from './StrategyTableSelector.vue'
import CustomTextArea from '@/components/CustomTextArea/index.vue'
import QuestionMarkTip from '@/views/components/QuestionMarkTip'
import { checkTextLen } from '@/utils/validate'
import { strategyPerms } from '@/config/permission/index'
import AuthButton from '@/components/AuthButton'
import LocalUpload from '@/components/Upload/LocalUpload'
import FileUploader from '@/components/Upload/FileUploader'
import userApi from "@api/modules/system/user";
import _ from "lodash";

export default {
  name: 'NewTaskStep1',
  components: {
    ShowConditionUpdateStrategy,
    StrategyTableSelector,
    CustomTextArea,
    AuthButton,
    LocalUpload,
    FileUploader,
    QuestionMarkTip,
    FactoryChannelSelect
  },
  props: {
    upgradeTriggerType : ''
  },
  data () {
    return {
      endOpen: false,
      strategyPerms,
      strategyTime: 1000,
      projectTime: 1200,
      projectIds: [],
      gcyApplyUsers: [],
      gcyAuditUsers: [],
      currentFileTarget: '',

      rules: {
        // lxhmodifyxccode
        name: [
          { required: true, message: this.$t('pleaseInput') },
          { validator: checkTextLen(50, true) }
        ],
        startTime: [{ required: true, validator: this.startTimeValidator }],
        endTime: [{ required: true, validator: this.endTimeValidator }],
        strategyId: [{ required: true, message: this.$t('pleaseSelect') }],
        type: [{ required: true, message: this.$t('pleaseSelect') }],
        forceUpgrade: [{ required: true, message: this.$t('pleaseSelect') }],
        silenceUpgrade: [{ required: true, message: this.$t('pleaseSelect') }],
        recordNo: [{ required: true, message: this.$t('pleaseInput') },{ validator: checkTextLen(200) }],
        remark: [{ required: true, message: this.$t('pleaseInput') },{ pattern: this.$patternRemark, message: this.$patternRemarkM }],
        factoryChannel: [{ required: true, message: this.$t('pleaseSelect') }],
        duration: [{ required: true, message: this.$t('pleaseInput') }]
      }
    }
  },
  computed: {
    ...mapState({
      gcyOtaUpdateScopeDictCode: state => state.dict.gcyOtaUpdateScopeDictCode,
      gcyOtaSupplierVerifyResultDictCode: state => state.dict.gcyOtaSupplierVerifyResultDictCode,
      // upgradeTriggerType: (state) => state.newTask.upgradeTriggerType,
      newTaskDataAll: (state) => state.newTask.newTaskData,
      taskFileConfig: (state) => state.newTask.taskFileConfig,
      instantUpdateTime: (state) => state.app.instantUpdateTime,
      taskType: (state) => state.task.taskType,
      slienceUpgradeType: (state) => state.task.slienceUpgradeType,
      forceUpgradeType: (state) => state.task.forceUpgradeType,
      prevStepNum: (state) => state.newTask.prevStepNum
    }),
    newTaskData(){
      //紧急OTA 为 自动升级
      // return this.newTaskDataAll['AUTO'];
      return this.newTaskDataAll[this.upgradeTriggerType];
    }
  },
  watch: {
    'newTaskData.projectId' (val) {
      const vm = this
      this.projectIds = [val]
      this.newTaskData.strategyId = ''
      this.strategyTime = new Date().getTime()
      // 新建时根据id获取项目名称
      this.$store.dispatch('getProjectDetailData', val).then((res) => {
        vm.newTaskData.projectName = res.data.name
      })
      this.clearSelectCars()
    },
    'newTaskData.startTime' (val) {
      this.newTaskData.startTimeStr = val ? `${val.format('YYYY-MM-DD HH:mm')}:00` : ''
    },
    'newTaskData.endTime' (val) {
      this.newTaskData.endTimeStr = val ? `${val.format('YYYY-MM-DD HH:mm')}:00` : ''
    },
    instantUpdateTime () {
      this.strategyTime = new Date().getTime()
      this.projectTime = new Date().getTime()
      // 表单绑定的是newTaskData 整个数据，reset会改变newTaskData.type
      // this.$refs.ruleForm && this.$refs.ruleForm.resetFields()
      this.$refs.ruleForm && this.$refs.ruleForm.clearValidate()
    },
    'newTaskData.copyId' : {
      handler(val){
        this.newTaskData.copyId = val ? this.getTaskInfor() : ''
      },
      immediate:true
    },
  },
  created() {
    this.$store.dispatch('getGcyOtaUpdateScopeDictCodeData')
    this.$store.dispatch('getGcyOtaSupplierVerifyResultDictCodeData')
  },
  mounted() {
    userApi.getUserPageData({ pageNo: 1, pageSize: 9999, roleIds: ['gcy_apply'] }).then(res => {
      this.gcyApplyUsers = res.data;
    });
    userApi.getUserPageData({ pageNo: 1, pageSize: 9999, roleIds: ['task_gcy_audit'] }).then(res => {
      this.gcyAuditUsers = res.data;
    });
  },
  methods: {
    ...mapMutations([
      'SET_PREV_STEPNUM',
    ]),
    getTaskInfor () {
      const vm = this
      vm.$api.getTaskInfor({ id: vm.newTaskData.copyId }).then((res) => {
        const {data} = res
        vm.newTaskData.strategyId = data.strategyId
        vm.newTaskData.strategyName = data.strategyName
        vm.newTaskData.type = data.type+''
        vm.newTaskData.forceUpgrade = data.forceUpgrade
        vm.newTaskData.silenceUpgrade = data.silenceUpgrade
        vm.newTaskData.recordNo = data.recordNo
        vm.newTaskData.remark = data.remark
        vm.newTaskData.taskGcyExt.supplierVerifyConclusion = data.taskGcyExt.supplierVerifyConclusion+''
        vm.newTaskData.taskGcyExt.productVerifyConclusion = data.taskGcyExt.productVerifyConclusion+''
        vm.newTaskData.duration = data.items[0].value
      })
    },
    confirmDates(dates){
      if(moment(dates[1]).diff(moment(dates[0]), 'seconds')==0){
        this.$message.warning('任务有效期的开始时间要小于结束时间 ')
        this.formData.expirationDate=[]
      }
    },
    // 修复策略之前需要判断(如果是从选择车辆页面倒回来的则需要询问) lxhmodifyxccode(以及prevStepNum相关的操作)
    changeStrategyBefore (val) {
      const _this = this

      // eslint-disable-next-line eqeqeq
      if (this.prevStepNum == 1) {
        // 从选择车辆页面倒回来的,选择策略变化时给提示
        this.$confirm({
          title: _this.$t('systemTip'),
          content: _this.$t('updateClearSelectedCarsTip'),
          onOk () {
            _this.SET_PREV_STEPNUM(-1);
            _this.changeStrategy(val)
            _this.clearSelectCars()
          },
          onCancel () {}
        })
      } else {
        this.changeStrategy(val)
      }
      this.$refs.ruleForm.validateField('strategyId')
    },
    changeStrategy (val) {
      this.newTaskData.strategyId = val
      this.newTaskData.strategyName = ''
      this.newTaskData.modelId = ''
      if (val) {
        this.$store.dispatch('getStrategyDetailData', {id:val}).then((res) => {
          this.newTaskData.strategyName = res.data.name
          this.newTaskData.modelId = res.data.modelId
        })
      }
    },
 
    // 批次名称输入框超过100字符提示
    lenMin(text){
      let flag = true
      text.trim()
      if(flag && text.length >= 100){
        this.$message.error('最多输入100字符')
        flag = false
      }else{
        return
      }
    },
    // 查看策略
    showStrategy () {
      // lxhmodifyxccode
      if (!this.newTaskData.strategyId) {
        this.$message.error(this.$t('firstPleaseSelectStrategy'))
        return
      }
      this.$refs.showStrategy.visible = true
    },
    // 修改唤醒通道
    changeoption ($event, key) {
      this.$set(this.newTaskData, key, $event)
      this.$refs.ruleForm.validateField(key)
    },
    // 提交验证
    getFormValid () {
      return new Promise((resolve, reject) => {
        this.$refs.ruleForm.validate((valid) => {
          if (!valid) {
            this.$message.error("请检查填写内容！")
            reject(valid)
          }
          resolve()
        })
      })
    },
    // 改变项目 策略 任务类型时清除已选车辆
    clearSelectCars () {
      if (this.newTaskData.selectCarIds.length) {
        this.newTaskData.selectCarIds = []
      }
    },
    /// ////时间验证
    startTimeValidator (rule, value, callback) {
      const vm = this
      const errors = []
      if (rule.required) {
        !value && errors.push(new Error(vm.$t('pleaseSelect')))
      }
      callback(errors[0])
    },
    endTimeValidator (rule, value, callback) {
      const vm = this
      const startValue = this.newTaskData.startTime
      const errors = []
      if (rule.required) {
        !value && errors.push(new Error(vm.$t('pleaseSelect')))
      }
      if (value && value < moment(moment().format('YYYY-MM-DD'))) {
        // 结束日期不能小于当前日期
        errors.push(new Error(vm.$t('newTaskTimeTip1')))
      }
      if (startValue) {
        if (value && startValue && value.valueOf() - (24 * 60 * 60 * 1000) < startValue.valueOf()) {
          // 开始与结束时间至少相差24小时
          errors.push(new Error(vm.$t('newTaskTimeTip2')))
        }
      }
      callback(errors[0])
    },
    disabledStartDate (startValue) {
      const endValue = this.newTaskData.endTime
      if (!startValue || !endValue) {
        return startValue < moment(moment().format('YYYY-MM-DD')) // 不能用HH:mm:ss 因为当前日期不能选 体验就不好
      }
      return startValue < moment(moment().format('YYYY-MM-DD')) || startValue.valueOf() > endValue.valueOf()
    },
    disabledEndDate (endValue) {
      const startValue = this.newTaskData.startTime
      if (!endValue || !startValue) {
        return endValue < moment(moment().format('YYYY-MM-DD'))
      }
      return startValue.valueOf() >= endValue.valueOf() || endValue < moment(moment().format('YYYY-MM-DD'))
    },
    handleStartOpenChange (open) {
      if (!open) {
        this.endOpen = true
      }
    },
    handleEndOpenChange (open) {
      this.endOpen = open
    },
    range(start, end){
      const result = [];
      for (let i = start; i < end; i++) {
          result.push(i);
      }
      return result;
    },
    disabledEndTime(date,type){
      let currentDay = moment().date();    //当下的时间
      let currentHours = moment().hours();
      let currentMinutes = moment().minutes(); 
      if(type=='start' && date){
        let settingHours = moment(date[0]).hours();
        let settingDay = moment(date[0]).date();
        if (date[0] && settingDay === currentDay && settingHours === currentHours) {
          return {       
            disabledHours: () => this.range(0, currentHours),         //设置为当天现在这小时，禁用该小时，该分钟之前的时间
            disabledMinutes: () => this.range(0, currentMinutes),
          };
        }else if (date[0] && settingDay === currentDay && settingHours > currentHours) {
            return { 
                disabledHours: () => this.range(0, currentHours),      //设置为当天现在这小时之后，只禁用当天该小时之前的时间 
                disabledMinutes: () => [],
            };   
        }else if (date[0] && settingDay === currentDay && settingHours < currentHours) {
            return {
                disabledHours: () => this.range(0, currentHours),      //若先设置了的小时小于当前的，再设置日期为当天，需要禁用当天现在这小时之前的时间和所有的分
                disabledMinutes: () => this.range(0, 59),
            }
        }else if (date[0] && settingDay > currentDay) {
            return {                                    
                disabledHours: () => [],                     //设置为当天之后的日期，则不应有任何时间分钟的限制
                disabledMinutes: () => [],
            }
        }
      }else if(type=='end' && date){ 
        let settingHours = moment(date[1]).hours();
        let settingDay = moment(date[1]).date();
        if (date[1] && settingDay === currentDay && settingHours === currentHours) {
          return {       
            disabledHours: () => this.range(0, currentHours),         //设置为当天现在这小时，禁用该小时，该分钟之前的时间
            disabledMinutes: () => this.range(0, currentMinutes),
          };
        }else if (date[1] && settingDay === currentDay && settingHours > currentHours) {
            return { 
                disabledHours: () => this.range(0, currentHours),      //设置为当天现在这小时之后，只禁用当天该小时之前的时间
                disabledMinutes: () => [],
            };   
        }else if (date[1] && settingDay === currentDay && settingHours < currentHours) {
            return {
                disabledHours: () => this.range(0, currentHours),      //若先设置了的小时小于当前的，再设置日期为当天，需要禁用当天现在这小时之前的时间和所有的分
                disabledMinutes: () => this.range(0, 59),
            }
        }else if (date[1] && settingDay > currentDay) {
            return {                                    
                disabledHours: () => [],                     //设置为当天之后的日期，则不应有任何时间分钟的限制
                disabledMinutes: () => [],
            }
        }
      }
    },
    disabledDate (current) {
      return current < moment().subtract(1,"days").endOf('day')
    },
    getPopupContainer () {
      return document.body
    },
    async getFormData () {
      await this.getFormValid()
      const vm = this
      if (this.newTaskData.channel === 1) {
        this.$message.error("规划院通道请到下一步补充审核信息！")
        return;
      }
      return new Promise((resolve, reject) => {
        resolve({  })
      });
    },
  }
}
</script>
<style lang="less" scoped>
.sjclStyle {
  position: relative;
  .sjclSelect {
    width: calc(100% - 60px);
  }
  .ant-btn {
    min-width: 50px;
    /*padding: 0;*/
    /*position: absolute;*/
    /*right: 0;*/
    /*top: 24px;*/
  }
}
</style>
